﻿<!DOCTYPE html>
<!--工艺介质编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .el-input__suffix {
            /* z-index: 9; */
        }

        #tcw0 .el-input__suffix {
            z-index: 10;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px" size="mini"
            label-position="right">
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="factor">
                                <el-input size="mini" v-model="Form.factor" autocomplete="off">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.ProcessMedium.Factor+mark.m}}</div>
                                    </template>
                                    <!--<el-select @visible-change="visibleChange" v-model="Form.factor" slot="suffix"
                            :placeholder="RisksManagement.ProcessMedium.Factor">
                            <el-option label="请选择" value=""></el-option>
                            <el-option v-for="item in Factor" :label="item.value" :value="item.key">
                            </el-option>
                        </el-select>-->
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.factor">
                                    <!-- 必填项添加 -->
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="introducer">
                                <el-input size="mini" v-model="Form.introducer" autocomplete="off">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.ProcessMedium.Introducer+mark.m}}</div>
                                    </template>
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.introducer">
                                    <!--<img src="/static/images/exclamation.png" alt="">-->
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="deviation">
                                <el-input size="mini" v-model="Form.deviation" autocomplete="off">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.ProcessMedium.Deviation+mark.m}}</div>
                                    </template>
                                    <!--<el-select @visible-change="visibleChange" v-model="Form.deviation" slot="suffix"
                            :placeholder="RisksManagement.ProcessMedium.Deviation">
                            <el-option label="请选择" value=""></el-option>
                            <el-option v-for="item in Deviation" :label="item.value" :value="item.key">
                            </el-option>
                        </el-select>-->
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.deviation">
                                    <!-- 必填项添加 -->
                                    <!--<img src="/static/images/exclamation.png" alt="">-->
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="riskLevel">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.ProcessMedium.RiskLevel+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.riskLevel" slot="suffix"
                                               :placeholder="RisksManagement.ProcessMedium.RiskLevel">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskLevel" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.riskLevel">
                                    <!-- 必填项添加 -->
                                    <!--<img src="/static/images/exclamation.png" alt="">-->
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="24">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="areaID">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{'区域'+mark.m}}
                                    </template>
                                    <treeselect v-model="Form.areaID" :options="AreaList" :flat="true" slot="suffix"
                                                style="line-height: 28px;width:70%;" :disable-branch-nodes="true"
                                                placeholder="请选择区域" />
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.areaID">

                                    <!--<img src="/static/images/exclamation.png" alt="">-->
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="riskOfViolation">
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{RisksManagement.ProcessMedium.CheckStandard+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.checkStandard"
                                          autocomplete="off"></el-input>
                                <span class="iputLineMust" v-if="!Form.riskOfViolation">
                                    <!-- 必填项添加 -->
                                    <!--<img src="/static/images/exclamation.png" alt="">-->
                                </span>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="riskOfViolation">
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{RisksManagement.ProcessMedium.RiskOfViolation+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.riskOfViolation"
                                          autocomplete="off"></el-input>
                                <span class="iputLineMust" v-if="!Form.riskOfViolation">
                                    <!-- 必填项添加 -->
                                    <!--<img src="/static/images/exclamation.png" alt="">-->
                                </span>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSubmit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>

    </div>
    <script type="text/javascript">
        Vue.component('treeselect', VueTreeselect.Treeselect)
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                AreaList:[],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                     areaID:null,
                    Factor: '',
                    Introducer: '',
                    Deviation: '',
                    RiskLevel: '',
                    CheckStandard: '',
                    RiskOfViolation: ''
                },
     
                RiskLevel: [],
                //表单验证
                rules: {
                    factor: [
                        verification.NotNull,
                    ],
                    //introducer: [
                    //    verification.NotNull,
                    //],
                    //deviation: [
                    //    verification.NotNull,
                    //],
                    //riskLevel: [
                    //    verification.NotNull
                    //],
                    //checkStandard: [
                    //    verification.NotNull,
                    //    { pattern: verification.StringLengthAtoB.t.format(5, 200), message: verification.StringLengthAtoB.m.format(5, 200), trigger: 'blur' }
                    //],
                    //riskOfViolation: [
                    //    verification.NotNull,
                    //    { pattern: verification.StringLengthAtoB.t.format(5, 200), message: verification.StringLengthAtoB.m.format(5, 200), trigger: 'blur' }
                    //],
                    //areaID: [
                    //    verification.NotNull
                    //],
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                   GetAreaList: function (type) {
                    var mythis = this;
                    myAjax("post", this, '/api/SysArea/GetList', { model: { Name: '', Code: '', SubFactory: null }, offset: 0, limit: 999 }
                        , function (response) {
                            console.log('1',response.data.pageData);
                            mythis.AreaList = menuHelper(response.data.pageData, null);
                        },
                        false);
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/YH_Process/Save', mythis.Form);
                            parent.app.GetLevelOne();
                        } else {
                            //验证失败
                            return false;
                        }
                    });

                },
                getData: function () {
                    getData(this, '/api/YH_Process/get?id=' + this.id);
                }
            },
            mounted: function () {
                this.RiskLevel = getDicData('03');
                //this.Factor = getDicData('31');
                //this.Introducer = getDicData('32');
                //this.Deviation = getDicData('33')
                this.GetAreaList();
                this.id = getUrlParam("id");
                this.getData();
            }
        });

        
           function menuHelper(list, pid) {
            
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                //temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>